#ifndef _NETWORK_H_
#define _NETWORK_H_		1
#include "std.h"
#include "pointlist.h"
#include "pthread_func.h"
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>

struct networkindex
{
	int udp_socket;
	struct pointlist rl_head;
	pthread_mutex_t rl_mutex;
	struct pointlist sl_head;
	pthread_mutex_t sl_mutex;
};

struct recvlist
{
	int recvid;
	struct sockaddr_in recvaddr;
	char data[1024];
	struct pointlist pointer;
	int flag;
};

struct sendlist
{
	int sendid;
	struct sockaddr_in sendaddr;
	char data[1024];
	struct pointlist pointer;
	int flag;
};
#define LOCAL_PORT 60000
#define LOCAL_IP "192.168.11.21"
extern int udp_server_init(struct networkindex *);
extern void recvlist_add(struct pointlist *, char *, size_t, struct sockaddr_in *);
extern int recvlist_getfrist(struct pointlist *, struct recvlist **);
extern void recvlist_show_foreach(struct pointlist *);
extern void recvlist_show(struct recvlist *);
extern void recvlist_del(struct pointlist *);
extern void sendlist_add(struct pointlist *, char *, size_t, struct sockaddr_in *);
extern int sendlist_getfrist(struct pointlist *, struct sendlist **);
extern void sendlist_show_foreach(struct pointlist *);
extern void sendlist_show(struct sendlist *);
extern void sendlist_del(struct pointlist *);
#endif		/* network.h end */